#ifndef DINGDANEXCHANGEWIDGET_H
#define DINGDANEXCHANGEWIDGET_H

#include <QDialog>
#include "dingdanexchangestandarditemmodel.h"
#include "dingdan.h"
#include "dingdanservice.h"
#include "productpicker.h"
#include "submitproductwidget.h"

namespace Ui {
class DingdanExchangeWidget;
}

class DingdanExchangeWidget : public QDialog
{
    Q_OBJECT

public:
    explicit DingdanExchangeWidget(QWidget *parent = nullptr);
    ~DingdanExchangeWidget();

    void showWithDingdan(Dingdan *dingdan);

    void setSelectedProduct(int index);

    QList<HistoryProduct*> getHistoryProducts();

signals:
    void importDingdanSuccess(Dingdan *dingdan);

private slots:
    void on_pushButtonClear_clicked();

    void on_lineEditSourceCount_editingFinished();

    void on_pushButtonImport_clicked();

    void on_pushButtonNewProduct_clicked();

private:
    Ui::DingdanExchangeWidget *ui;
    SubmitProductWidget newProductWidget;

    DingdanExchangeStandardItemModel *modelSource;
    DingdanExchangeStandardItemModel *modelTarget;

    Dingdan *dingdan;
    DingdanService dingdanService;
    ProductService productService;

    DingdanDetail *sourceDetail;
    Product *sourceProduct;
    DingdanDetail *targetDetail;
    Product *targetProduct;

    ProductPicker productPicker;
    UserRelation *relation;

    int currentRow;
    int type;
};

#endif // DINGDANEXCHANGEWIDGET_H
